package com.fenghongzhang.test;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ViewGroup;

public class MyGroup extends ViewGroup {

    int mWidth;
    private static final String TAG = "MyGroup";

    public MyGroup(Context context) {
        super(context);
    }

    public MyGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//        getChildMeasureSpec()
        int mode = MeasureSpec.getMode(widthMeasureSpec);
        int size = MeasureSpec.getSize(widthMeasureSpec);
        Log.i(TAG, "onMeasure: +"+size);
        if(mode == MeasureSpec.EXACTLY){
            int measuredWidth = getMeasuredWidth();
            Log.i(TAG, "onMeasure: "+measuredWidth); //1080


        }else if(mode == MeasureSpec.AT_MOST){
            int measuredWidth = getMeasuredWidth();
            Log.i(TAG, "onMeasure:111 "+measuredWidth);
        }
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
//        int width = getWidth();
//        Log.i(TAG, "onLayout: "+width);
    }
}
